
import { _decorator, Component, Node, Label, Button } from 'cc';
import PlayerData from '../../Script/Common/PlayerData';
const { ccclass, property } = _decorator;

@ccclass('SpinBtn')
export class SpinBtn extends Component {

    onLoad() {

        this.checkFree();

    }

    @property(Label)
    protected freeCount: Label = null;

    checkFree() {
        let data = PlayerData.getPlayerData();
        let count = data.spinData.count;
        this.freeCount.string = count + "";
        this.node.active = data.spinData.count < 3;
    }

    onClick() {
        let data = PlayerData.getPlayerData();
        data.spinData.count += 1;
        data.spinData.lastTime = Date.now();

        this.freeCount.string = data.spinData.count + "";

        if (data.spinData.count >= 3) {
            this.node.active = false;
        }
    }

}
